package com.guoheng.hazard.sys.controller;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.manager.download.DownloadManager;
import com.guoheng.hazard.sys.model.dto.DownloadDTO;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 类功能描述:　DownloadController
 *
 * @author fbl
 * @date 2019-10-15 11 :56
 */
@RestController
@Api(value = "文件下载")
@CrossOrigin
public class DownloadController {

    @Resource
    DownloadManager downloadManager;

    /**
     * 文件下载
     *
     * @param downloadDTO 下载路径
     * @return
     */
    @PostMapping(value = "basic/notice/downloadFile")
    public Result downloadFile(@RequestBody  @Valid DownloadDTO downloadDTO) throws Exception {
       return downloadManager.downLoadFromUrl(downloadDTO);
    }

}
